package Test.Exam;

import java.util.Scanner;

/**
 * @ClassName problem_1
 * @since: 2024/3/9 09:44
 * @auth: kirito
 * @description:
 **/
public class problem_1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int k = in.nextInt();
        char[] chars = in.next().toCharArray();
        int mCount = 0;
        int tCount =0;
        for (char c : chars) {
            if (String.valueOf(c).equals("M")) {
                mCount++;
            }
            if (String.valueOf(c).equals("T")) {
                tCount++;
            }
        }
        int max = mCount + tCount + k;
        if (max > n) {
            System.out.println(n);
        }else{
            System.out.println(mCount + tCount + k);
        }

    }
}
